package com.ssy.lingxi.member.merchant.controller.paas;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.api.model.vo.paas.CountryAreaVO;
import com.ssy.lingxi.member.merchant.api.model.vo.paas.CountryCodeUpdateInsertVO;
import com.ssy.lingxi.member.merchant.service.paas.IPaasCountryCodeAreaService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 系统初始化 - 国家代码接口
 * @author 万宁
 * @version 2.0.0
 * @date 2020-07-14
 */
@RestController
@RequestMapping("/paas/country")
public class CountryCodeAreaController {
    @Resource
    private IPaasCountryCodeAreaService countryCodeAreaService;

    /**
     * 根据枚举值定义，新增或更新国家代码
     * @param codeVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/code/update/insert", method = RequestMethod.POST)
    public Wrapper<Void> updateOrInsertCountryCode(@RequestBody @Valid CountryCodeUpdateInsertVO codeVO) {
        return countryCodeAreaService.updateOrInsertCountryCode(codeVO);
    }

    /**
     * 删除国家代码
     * @param codeVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/code/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteCountryCode(@RequestBody @Valid CountryCodeUpdateInsertVO codeVO) {
        return countryCodeAreaService.deleteCountryCode(codeVO);
    }

    /**
     * 新增区域编码
     * @param areaVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/area/add", method = RequestMethod.POST)
    public Wrapper<Void> addCountryArea(@RequestBody @Valid List<CountryAreaVO> areaVO) {
        return countryCodeAreaService.addCountryArea(areaVO);
    }
}
